#! /usr/bin/python
# encoding=utf-8
# Created by Fenglu Niu on 2025/5/27 14:41
from typing import List

from sqlmodel import Session, select

import common
from api.entity import CaseFeedback


class CaseFeedbackService(object):
    @staticmethod
    def create_feedback(case_feedbacks: List[CaseFeedback], session: Session, autocommit: bool = True):
        try:
            session.add_all(case_feedbacks)
            if autocommit:
                session.commit()
        except Exception as e:
            common.get_logger().error('创建案件反馈报错：{}', e)
            session.rollback()

    @staticmethod
    def list_feedback(case_id, session):
        return session.exec(select(CaseFeedback).where(CaseFeedback.case_id == case_id)).all()